<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/common.css" />
		<link rel="stylesheet" href="../../css/order/invoice.css" />
	</head>

	<body>
		<div id="invoice">
			<header class="mui-bar mui-bar-nav">
				<a class="mui-action-back mui-icon mui-icon-arrowleft mui-pull-left"></a>
				<h1 class="mui-title">发票信息</h1>
			</header>
			<div class="mui-content">
				<div class="invoice_title">
					<div>发票类型</div>
					<div class="invoice_cls">纸质普通发票</div>
				</div>
				<div class="detailed">
					<div>发票明细</div>
					<div class="select">
						<div class="noinvoice">
							<div class="check"></div>
							<div>不需要发票</div>
						</div>
						<div class="detaileds">
							<div></div>
							<div>明细</div>
						</div>
					</div>
				</div>
				<div class="rise">
					<div class="raised">
						<div style="font-size:14px;">发票抬头</div>
						<div class="invoicetype">
							<div class="check"></div>
							<div>个人</div>
						</div>
						<div class="invoicetype">
							<div></div>
							<div>单位</div>
						</div>
					</div>
					<div class="company"><input type="text" placeholder="可输入个人/单位名称" /></div>
					<div class="paragraph"><input type="text" placeholder="请输入税号" /></div>
				</div>
				<div class="need">
					<div>发票须知：</div>
					<div>1.依照税局最新开票法规，纸质普通发票和电子普通发票，开具内 容均为明细
					</div>
					<div>2.开票金额为用户实际支付的金额（不含礼品卡与不支持该发票类 型的商品）实付金额电子发片可在确定收货后，再“订单详情页”或 “售后服务”可查看。
					</div>
					<div>3.未随箱寄出的纸质发票会在发货后15-30个工作日单独寄出</div>
					<div>4.增值税专用发票将会在所有包裹发货后15-30个工作日单独寄出</div>
					<div>5.单笔订单只支持开具一种类型的发票</div>
					<div>6.年购订单发票随每期子单寄出</div>
				</div>
			</div>
			<div class="preservation"><button type="button" class="mui-btn mui-btn-danger">保存</button></div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/libs/zepto.js"></script>
		<script src="../../js/common.js"></script>
		<script type="text/javascript">
			mui.init({
				swipeBack:true
			})
			$(".preservation").css('top', document.documentElement.clientHeight - 44)
			$('.select>div').on('tap', function() {
				$('.select div').removeClass('check')
				$(this).find('div').eq(0).addClass('check')
				$(this).index() == 1 ? $(".rise").show() : $(".rise").hide()
			})

			$('.invoicetype').on('tap', function() {
				$('.invoicetype div').removeClass('check')
				$(this).find('div').eq(0).addClass('check')
			})

			$(".preservation").on('tap', function() {
				if(!$(".select .check").parent().index()) {
					mui.back()

					var list = plus.webview.getWebviewById('../order/confirmorder.html');
					mui.fire(list, 'invoice', { //触发自定义事件
						datafoor: ''
					});
				} else {
					if(common.replace($(".company input").val()) == '') {
						common.toast('个人/单位名称不能为空')
						return
					}else if(common.replace($(".paragraph input").val()) == ''){
						common.toast('税号不能为空')
						return
					}

					var datafoor = {
						typeId: 1,
						content_id: 2,
						titleId: $(".raised .check").parent().index(),
						company: $(".company input").val(),
						duty:$(".paragraph input").val()
					}

					common.jsonAjax('/submitOrder/saveInvoice', datafoor, function(data) {
						if(data.code == 1) {
							datafoor.invoiceId = data.data.invoiceId
							var list = plus.webview.getWebviewById('../order/confirmorder.html');
							mui.fire(list, 'invoice', { //触发自定义事件
								datafoor: datafoor
							});
							mui.back()
						} else {
							if(data.resultMsg) {
								common.toast(data.resultMsg)
							} else {
								console.log(data)
							}
						}
					}, false, 'post')
				}
			})
		</script>
	</body>

</html>